using System.Data;
using Crosland.Offline.Core;
using Crosland.Framework.Base;

namespace Crosland.Offline.Data.Helper
{

    public class ClienteHelper : DaoHelperBase
    {
        public ClienteHelper() : base(Entidad, ConstansBase.Aplicacion) 
        {
        }

        public Cliente Create(IDataReader dr)
        {
            Cliente entity = new Cliente();

            int iKunnr = dr.GetOrdinal(this.Kunnr);
            if (!dr.IsDBNull(iKunnr)) entity.ID = dr.GetString(iKunnr);

            int iKtokd = dr.GetOrdinal(this.Ktokd);
            if (!dr.IsDBNull(iKtokd)) entity.Ktokd = dr.GetString(iKtokd);

            int iAnred = dr.GetOrdinal(this.Anred);
            if (!dr.IsDBNull(iAnred)) entity.Anred = dr.GetString(iAnred);

            int iName1 = dr.GetOrdinal(this.Name1);
            if (!dr.IsDBNull(iName1)) entity.Name1 = dr.GetString(iName1);

            int iName2 = dr.GetOrdinal(this.Name2);
            if (!dr.IsDBNull(iName2)) entity.Name2 = dr.GetString(iName2);

            int iStras = dr.GetOrdinal(this.Stras);
            if (!dr.IsDBNull(iStras)) entity.Stras = dr.GetString(iStras);

            int iStrSuppl1 = dr.GetOrdinal(this.StrSuppl1);
            if (!dr.IsDBNull(iStrSuppl1)) entity.StrSuppl1 = dr.GetString(iStrSuppl1);

            int iStrSuppl2 = dr.GetOrdinal(this.StrSuppl2);
            if (!dr.IsDBNull(iStrSuppl2)) entity.StrSuppl2 = dr.GetString(iStrSuppl2);

            int iOrt01 = dr.GetOrdinal(this.Ort01);
            if (!dr.IsDBNull(iOrt01)) entity.Ort01 = dr.GetString(iOrt01);

            int iOrt02 = dr.GetOrdinal(this.Ort02);
            if (!dr.IsDBNull(iOrt02)) entity.Ort02 = dr.GetString(iOrt02);

            int iLand1 = dr.GetOrdinal(this.Land1);
            if (!dr.IsDBNull(iLand1)) entity.Land1 = dr.GetString(iLand1);

            int iRegio = dr.GetOrdinal(this.Regio);
            if (!dr.IsDBNull(iRegio)) entity.Regio = dr.GetString(iRegio);

            int iTelf1 = dr.GetOrdinal(this.Telf1);
            if (!dr.IsDBNull(iTelf1)) entity.Telf1 = dr.GetString(iTelf1);

            int iTelf2 = dr.GetOrdinal(this.Telf2);
            if (!dr.IsDBNull(iTelf2)) entity.Telf2 = dr.GetString(iTelf2);

            int iKnurl = dr.GetOrdinal(this.Knurl);
            if (!dr.IsDBNull(iKnurl)) entity.Knurl = dr.GetString(iKnurl);

            int iStcd1 = dr.GetOrdinal(this.Stcd1);
            if (!dr.IsDBNull(iStcd1)) entity.Stcd1 = dr.GetString(iStcd1);

            int iStcdt = dr.GetOrdinal(this.Stcdt);
            if (!dr.IsDBNull(iStcdt)) entity.Stcdt = dr.GetString(iStcdt);

            int iKukla = dr.GetOrdinal(this.Kukla);
            if (!dr.IsDBNull(iKukla)) entity.Kukla = dr.GetString(iKukla);

            return entity;
        }


        #region Mapeo de Campos

        public const string Entidad = "Cliente";
        public string Kunnr = "KUNNR";
        public string Ktokd = "KTOKD";
        public string Anred = "ANRED";
        public string Name1 = "NAME1";
        public string Name2 = "NAME2";
        public string Stras = "STRAS";
        public string StrSuppl1 = "STR_SUPPL1";
        public string StrSuppl2 = "STR_SUPPL2";
        public string Ort01 = "ORT01";
        public string Ort02 = "ORT02";
        public string Land1 = "LAND1";
        public string Regio = "REGIO";
        public string Telf1 = "TELF1";
        public string Telf2 = "TELF2";
        public string Knurl = "KNURL";
        public string Stcd1 = "STCD1";
        public string Stcdt = "STCDT";
        public string Kukla = "KUKLA";

        #endregion
    }
}
